package com.mt.roll.wms.controller;

import com.mt.roll.core.base.BaseController;
import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.params.IdParam;
import com.mt.roll.core.vo.R;
import com.mt.roll.wms.params.LocationQueryParam;
import com.mt.roll.wms.params.LocationShelfProcessQueryParam;
import com.mt.roll.wms.service.LocationService;
import com.mt.roll.wms.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;
import java.util.List;

@RestController
@RequestMapping(CommonConstant.API_MODULE_WMS + "location")
@Slf4j
@Api(value = "库位信息", tags = "库位信息", hidden = false)
public class LocationController extends BaseController {

    @Autowired
    private LocationService locationService;

    @PostMapping(value = "list")
    @ApiOperation(value = "获取库位列表")
    private R<List<LocationVo>> list(@Validated({Default.class}) @RequestBody LocationQueryParam locationQueryParam) {
        return locationService.list(locationQueryParam);
    }

    @PostMapping(value = "shelfList")
    @ApiOperation(value = "获取货架存储箱列表")
    private R<List<LocationShelfListVO>> shelfList() {
        return locationService.getShelfList();
    }

    @PostMapping(value = "getAllLocationByProcessIdOrShelfId")
    @ApiOperation(value = "查询所有库位信息 依据工序id 或者 货架id ")
    private R<List<LocationProcessVo>> getAllLocationByProcessIdOrShelfId(@RequestBody LocationShelfProcessQueryParam locationShelfProcessQueryParam) {
        return locationService.getAllLocationByProcessIdOrShelfId(locationShelfProcessQueryParam);
    }

    @PostMapping(value = "getSubByLocationNo")
    @ApiOperation(value = "查询库位中基板信息 依据库位编码locationNo")
    private R<SubListAndStorageFidVo> getSubByLocationNo(@RequestBody IdParam idParam) {
        return locationService.getSubListAndStorageFidByLocationNum(idParam);
    }
}
